<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        li{
            list-style: none;
        }
        ul , div{
            width: 600px;
            height: 60px;
            border: 1px solid;
            box-sizing: border-box;
            margin: 50px auto;
            display: flex;
        }
        li{
            line-height: 60px;
            text-align: center;
            color: #000;
            border: 1px solid;
            box-sizing: border-box;
            width: 120px;
        }
        .active{
            background-color: orange;
            color: white;
        }
        p{
            display: none;
        }
    </style>
</head>
<body>
   <ul>
    <li class="active">1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
   </ul>
   <div>
    <p style="display: block;">p-1</p>
    <p>p-2</p>
    <p>p-3</p>
    <p>p-4</p>
    <p>p-5</p>
   </div>
   <script>
    let lis = document.querySelectorAll('li')
    let div = document.querySelector('div')
    let p = document.querySelectorAll('div p')
    console.log(lis);
    console.log(p);
    lis.forEach((item,index)=>{
        item.onclick= function(){
            console.log(item);
            // 排他思想
            let childrens= item.parentNode.children
            console.log(childrens);
            for(let lim of childrens){
                lim.className = ''
            }
            for(let pm of p){
                pm.style.display="none"    
            }
            // 点击修改类名
            item.classList.add('active')
            // 点击后修改div内容
            // div.innerText = item.innerText
            // 点击后显示对应的p元素
            p[index].style.display = 'block'    
        }
        
    })
    
   </script>
    
</body>
</html>